#define WINAPI_ADAPTOR
#include "winapi_adaptor.h"


typedef UINT (*GetDpiForWindowProc)(HWND hwnd);
typedef UINT (*GetDpiForSystemProc)();

static GetDpiForWindowProc GetDpiForWindow_;
static GetDpiForSystemProc GetDpiForSystem_;

#define CONCAT(a,b) a##b
#define LoadAPI(name) CONCAT(name,_) = (CONCAT(name,Proc))GetProcAddress(mod, #name);

VOID InitWinAPI(){
    HMODULE mod = LoadLibrary(TEXT("user32.dll"));
    if(mod){
        LoadAPI(GetDpiForWindow);
        LoadAPI(GetDpiForSystem);      
    }
}


static UINT OldGetDPI(){
    HDC dc = GetDC(NULL);
    UINT dpi = GetDeviceCaps(dc, LOGPIXELSX);
    ReleaseDC(NULL, dc);
    return dpi;
}

UINT WIN32_GetDpiForWindow(HWND hwnd){
    if(GetDpiForWindow_)return GetDpiForWindow_(hwnd);
    return OldGetDPI();
}


UINT WIN32_GetDpiForSystem(){
    if(GetDpiForSystem_)return GetDpiForSystem_();
    return OldGetDPI();
}



